home *** CD-ROM | disk | FTP | other *** search
/ Java for 3D & VRML Worlds / Java for 3d and VRML Worlds.iso / doc / homepage / tutorials / lesson2 / conemove.java < prev    next >
Text File  |  1996-08-26  |  831b  |  29 lines

  1. import vrml.*;
  2. import vs.*;
  3.  
  4. public class conemove extends Script {
  5.   SFRotation theRot = (SFRotation)getEventOut("theRot");
  6.  
  7.   float newTrans[] = new float[4];
  8.   float transPt[] = new float[3];
  9.  
  10.   public conemove() {
  11.     newTrans[0] = 1;     // axis around which to rotate
  12.     newTrans[1] = 0;     // "
  13.     newTrans[2] = 0;     // "
  14.     newTrans[3] = 0;  // angle to rotate by (in radians)
  15.   }
  16.  
  17.   public void clicked(ConstSFBool ev, ConstSFTime time) {
  18.     if (ev.getValue() == true) {    // if mouse is clicked DOWN, ignore
  19.       return;
  20.     } 
  21.     else {          // if mouse is clicked UP, perform the rotation
  22.         newTrans[3] += 0.314f; // angle
  23.         if(newTrans[3] > 6.284f)
  24.            newTrans[3] -= 6.284f; // pin to the range 0-360 degrees
  25.         theRot.setValue(newTrans);
  26.     }
  27.   }
  28. }
  29.